package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * ShoppingCartMapper
 *
 * @author liliudong
 * @version 1.0
 * @description
 * @date 2023/8/2 14:21
 */
@Mapper
public interface ShoppingCartMapper {
    /**
     * 选择一个
     *
     * @param cartQuery 购物车查询
     * @return {@link ShoppingCart}
     */
    ShoppingCart selectOne(ShoppingCart cartQuery);

    /**
     * 更新通过id
     *
     * @param shoppingCart 购物车
     */
    void updateById(ShoppingCart shoppingCart);

    /**
     * 插入
     *
     * @param shoppingCart 购物车
     */
    void insert(ShoppingCart shoppingCart);

    /**
     * 选择列表
     *
     * @param shoppingCart 购物车
     * @return {@link List}<{@link ShoppingCart}>
     */
    List<ShoppingCart> selectList(ShoppingCart shoppingCart);

    /**
     * 按用户id删除 当且仅有一个参数时，参数名可以任意取（拿）
     *
     * @param userId 当前userId
     */
    @Delete("delete from shopping_cart where user_id = #{usaerId}")
    void deleteByUserId(Long userId);

    /**
     * 批量插入
     *
     * @param shoppingCarts 购物车
     */
    void insertBatch(List<ShoppingCart> shoppingCarts);
}
